engine.animated_object.update(anim_objs['segment1'], engine.current_frame.number)
engine.animated_object.update(anim_objs['segment2'], engine.current_frame.number)
engine.animated_object.update(anim_objs['segment3'], engine.current_frame.number)
engine.animated_object.update(anim_objs['segment4'], engine.current_frame.number)
engine.animated_object.update(anim_objs['segment5'], engine.current_frame.number)

skeleton['bones']['segment1']['bone'].angle = anim_objs['segment1'].rotation
skeleton['bones']['segment2']['bone'].angle = anim_objs['segment2'].rotation
skeleton['bones']['segment3']['bone'].angle = anim_objs['segment3'].rotation
skeleton['bones']['segment4']['bone'].angle = anim_objs['segment4'].rotation
skeleton['bones']['segment5']['bone'].angle = anim_objs['segment5'].rotation
json_utils.skeleton.update_skeleton_root(skeleton, {
    skeleton['position'][1],
    skeleton['position'][2]
})

blitAnimObjFromBone(anim_objs['segment1'], skeleton['bones']['segment1']['bone'])
blitAnimObjFromBone(anim_objs['segment2'], skeleton['bones']['segment2']['bone'])
blitAnimObjFromBone(anim_objs['segment3'], skeleton['bones']['segment3']['bone'])
blitAnimObjFromBone(anim_objs['segment4'], skeleton['bones']['segment4']['bone'])
blitAnimObjFromBone(anim_objs['segment5'], skeleton['bones']['segment5']['bone'])

if draw_skeleton then
    for bone, _ in pairs(skeleton['bones']) do
        bones.drawBone(skeleton['bones'][bone]['bone'])
    end
end
